home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / ptime_10.zip / DISPLAY.ASM < prev    next >
Assembly Source File  |  1992-10-04  |  3KB  |  131 lines

  1.         ideal
  2.  
  3.         include    "PhilTime.I"
  4.  
  5. textAttribute   equ     (blinking*128+backgroundColor*16+forgroundColor)
  6.  
  7. if        redrawTime GT firstRedraw
  8. startingCounter    equ    (redrawTime-firstRedraw)
  9. else
  10. startingCounter    equ    0
  11. endif
  12.  
  13. if        backgroundColor GT 7
  14.         display "Illegal background color"
  15. err
  16. endif
  17.  
  18. segment        displayTime
  19.                 assume  cs:displayTime
  20.  
  21. label        displayFirst    byte
  22.  
  23. oldTickHandler    dd    ?
  24. ticksSinceDraw  dw      startingCounter
  25. ticksPerMinute  dw      1093
  26. clockPosition   dd      0b800h:150
  27. biosDataSegment    dw    0040h
  28.  
  29. proc        tickHandler    far
  30.         pushf
  31.         sti
  32.                 push    ax
  33.                 push    bx
  34.                 push    dx
  35.         push    di
  36.         push    ds
  37.         push    es
  38.  
  39.         push    cs
  40.         pop    ds
  41.                 assume  ds:displayTime
  42.  
  43.                 ;see if enough time has passed
  44.                 inc     [ticksSinceDraw]
  45.                 cmp     [ticksSinceDraw],redrawTime
  46.                 jb      done
  47.                 mov     [ticksSinceDraw],0
  48.  
  49.                 mov     ds,[biosDataSegment]
  50.                 assume  ds:nothing
  51.  
  52.                 ;see if a display is required
  53. if        watchScrollLock
  54.                 test    [byte ptr ds:17h],10h
  55.         jnz    done
  56. endif
  57. if        watchVideoMode
  58.                 mov     al,[ds:49h]
  59.                 cmp     al,2
  60.         jb    done
  61.                 cmp     al,3
  62.         ja    done
  63. endif
  64.  
  65.         ;update the screen
  66.                 mov     dx,[ds:6ch]     ;bx:dx == number of clock
  67.                 mov     bx,[ds:6eh]     ;ticks since midnight
  68.                 les     di,[clockPosition]
  69. if        twelveHourTime
  70.         add    bl,12
  71. adjust12:    cmp    bl,12
  72.         jbe    adjusted12
  73.         sub    bl,12
  74.         jmp    adjust12
  75. adjusted12:
  76. endif
  77.                 call    printBL
  78.                 mov     al,':'
  79.                 stosw
  80.                 mov     ax,dx
  81.                 xor     dx,dx
  82.                 div     [ticksPerMinute]
  83.                 mov     bl,al
  84.                 call    printBL
  85.  
  86. if        NOT leadingZero
  87.         cmp    [byte ptr es:di-10],'0'
  88.         jne    noLeadingZero
  89.         mov    [byte ptr es:di-10],' '
  90. noLeadingZero:
  91. endif
  92.  
  93. done:
  94.         pop    es
  95.         pop    ds
  96.         pop    di
  97.                 pop     dx
  98.                 pop     bx
  99.                 pop     ax
  100.         popf
  101.         jmp    [cs:oldTickHandler]
  102. endp        tickHandler    
  103.  
  104. ;       IN: BL is the number (00-99) to be printed
  105. ;       IN: ES:DI is the position to print to
  106. ;       OUT: ES:DI is advanced 2 spaces
  107. ;       OUT: AH == textAttribute
  108. ;       OUT: AL is modified
  109. ;       OUT: BL is modified
  110. proc            printBL
  111.                 mov     ax,textAttribute*100h+'0'
  112. setTensDigit:   cmp     bl,10
  113.                 jb      drawTensDigit
  114.                 sub     bl,10
  115.                 inc     al
  116.                 jmp     setTensDigit
  117. drawTensDigit:  stosw
  118.                 mov     al,'0'
  119.                 add     al,bl
  120.                 stosw
  121.                 ret
  122. endp            printBL
  123.  
  124.                 label           displayLast     byte
  125.  
  126. ends        displayTime
  127.  
  128.         public    displayFirst,displayLast,tickHandler,oldTickHandler
  129.  
  130.         end
  131.